package person.zjh.kaoyansharehub.utils;

import java.security.SecureRandom;

/**
 * @description: 随机生成类
 * @author 郑佳豪
 * @date 2025/1/19 23:08
 * @version 1.0
 */

public class RandomGenerator {

    private static final String NUMBER = "0123456789";
    private static final SecureRandom RANDOM = new SecureRandom();


    /**
     * 随机生成账号
     */
    public static String generatorAccount(){
        return generatorAccount(11); //指定生成长度为11的账号
    }

    /**
     * 随机生成指定长度的账号
     * @param len 长度
     */
    public static String generatorAccount(int len){
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < len; i++) {
            int randomIndex = RANDOM.nextInt(NUMBER.length());
            sb.append(NUMBER.charAt(randomIndex));
        }
        return sb.toString();
    }

}
